{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 2 3]\n",
      " [2 3 4]\n",
      " [3 4 5]]\n",
      "<class 'numpy.ndarray'>\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "princess_count = 3\n",
    "\n",
    "w1 = np.array([1,2,3])\n",
    "w2 = np.array([2,3,4])\n",
    "w3 = np.array([3,4,5])\n",
    "\n",
    "#                   公主1         公主2      公主3\n",
    "# 王子1 彩礼          1            2            3\n",
    "# 王子2 彩礼          2            3            4\n",
    "# 王子3 彩礼          3            4            5\n",
    "\n",
    "prices = np.vstack([w1,w2,w3]) # np.transpose()\n",
    "\n",
    "print(prices)\n",
    "print(type(prices))\n",
    "\n",
    "# 如果是一个元素一个元素输入，这工作可以在输入的时候做\n",
    "# a,b,c = np.hsplit(prices,3)\n",
    "# print(a)\n",
    "# print(\"---------------------------a\")\n",
    "# print(b)\n",
    "# print(\"---------------------------\")\n",
    "# print(c)\n",
    "\n",
    "def get_largest(w_prices):\n",
    "    index = -1\n",
    "    ele = -1\n",
    "    result = ele,index\n",
    "    for one in w_prices:\n",
    "        index += 1\n",
    "        if(one > ele):\n",
    "            ele = one\n",
    "            result = ele,index\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3]\n",
      "[[2 3]\n",
      " [3 4]]\n",
      "[4]\n",
      "[[1 3]\n",
      " [2 4]]\n",
      "[5]\n",
      "[[1 2]\n",
      " [2 3]]\n"
     ]
    }
   ],
   "source": [
    "princess_prices = np.hsplit(prices,princess_count) # 原矩阵纵向切片\n",
    "y_index = -1 # 列索引\n",
    "for price in princess_prices:\n",
    "    y_index += 1\n",
    "    y_largest,x_index = get_largest(price) # 某个公主获得的最大彩礼\n",
    "    # print(x_index)\n",
    "    # print(y_index)\n",
    "    # print(y_largest)\n",
    "    # print(price)\n",
    "    \n",
    "    # 余子式\n",
    "    cofactor = np.delete(prices,x_index,axis = 0)\n",
    "    cofactor = np.delete(cofactor,y_index,axis = 1)\n",
    "    print(cofactor)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
